diff --git a/utils/rbutilqt/CMakeLists.txt b/utils/rbutilqt/CMakeLists.txt
--- a/utils/rbutilqt/CMakeLists.txt
+++ b/utils/rbutilqt/CMakeLists.txt
@@ -289,8 +289,53 @@
     set(QUAZIP_LIBRARY quazip)
 endif()
 
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(MSPACK libmspack)
+if(NOT ${MSPACK_FOUND})
+    add_library(mspack
+        #mspack/cabc.c
+        mspack/cabd.c
+        mspack/cab.h
+        #mspack/chmc.c
+        #mspack/chmd.c
+        #mspack/chm.h
+        mspack/des.h
+        #mspack/hlpc.c
+        #mspack/hlpd.c
+        #mspack/hlp.h
+        #mspack/kwajc.c
+        #mspack/kwajd.c
+        #mspack/kwaj.h
+        #mspack/litc.c
+        #mspack/litd.c
+        #mspack/lit.h
+        #mspack/lzssd.c
+        #mspack/lzss.h
+        mspack/lzxc.c
+        mspack/lzxd.c
+        mspack/lzx.h
+        mspack/mspack.h
+        mspack/mszipc.c
+        mspack/mszipd.c
+        mspack/mszip.h
+        mspack/qtmd.c
+        mspack/qtm.h
+        mspack/readbits.h
+        mspack/readhuff.h
+        mspack/sha.h
+        mspack/system-mspack.c
+        mspack/system-mspack.h
+        #mspack/szddc.c
+        #mspack/szddd.c
+        #mspack/szdd.h
+        )
+
+    target_include_directories(mspack PUBLIC ${CMAKE_CURRENT_LIST_DIR}/mspack)
+    set(MSPACK_LIBRARIES mspack)
+endif()
+
 target_link_libraries(rbbase
-    cutelogger ${QUAZIP_LIBRARY} mspack bspatch rbspeex
+    cutelogger ${QUAZIP_LIBRARY} ${MSPACK_LIBRARIES} bspatch rbspeex
     voicefont sansapatcher ipodpatcher chinachippatcher
     mkamsboot mkimxboot mkmpioboot mktccboot mks5lboot
     Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Network)
@@ -332,47 +377,6 @@ target_link_libraries(cutelogger PUBLIC Qt${QT_VERSION_MAJOR}::Core)
 target_compile_definitions(cutelogger PUBLIC CUTELOGGER_STATIC)
 set_property(TARGET cutelogger PROPERTY AUTOMOC ON)
 
-add_library(mspack
-    #mspack/cabc.c
-    mspack/cabd.c
-    mspack/cab.h
-    #mspack/chmc.c
-    #mspack/chmd.c
-    #mspack/chm.h
-    mspack/des.h
-    #mspack/hlpc.c
-    #mspack/hlpd.c
-    #mspack/hlp.h
-    #mspack/kwajc.c
-    #mspack/kwajd.c
-    #mspack/kwaj.h
-    #mspack/litc.c
-    #mspack/litd.c
-    #mspack/lit.h
-    #mspack/lzssd.c
-    #mspack/lzss.h
-    mspack/lzxc.c
-    mspack/lzxd.c
-    mspack/lzx.h
-    mspack/mspack.h
-    mspack/mszipc.c
-    mspack/mszipd.c
-    mspack/mszip.h
-    mspack/qtmd.c
-    mspack/qtm.h
-    mspack/readbits.h
-    mspack/readhuff.h
-    mspack/sha.h
-    mspack/system-mspack.c
-    mspack/system-mspack.h
-    #mspack/szddc.c
-    #mspack/szddd.c
-    #mspack/szdd.h
-    )
-
-target_include_directories(mspack PUBLIC ${CMAKE_CURRENT_LIST_DIR}/mspack)
-
-
 # Unit tests
 add_executable(test_compareversion
     base/utils.cpp
diff --git a/utils/rbutilqt/base/mspackutil.h b/utils/rbutilqt/base/mspackutil.h
--- a/utils/rbutilqt/base/mspackutil.h
+++ b/utils/rbutilqt/base/mspackutil.h
@@ -21,7 +21,7 @@
 
 #include <QtCore>
 #include "archiveutil.h"
-#include "mspack/mspack.h"
+#include <mspack.h>
 
 class MsPackUtil : public ArchiveUtil
 {
